package club.emergency.wechat.manager.search.consumer.service.fallback_factory;

import club.emergency.wechat.common.response.ResponseEntity;
import club.emergency.wechat.common.response.StatusCode;
import club.emergency.wechat.manager.search.consumer.service.ManagerSearchConsumer;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * Create with IntelliJ IDEA
 * Project Name: wechat
 * Package Name: club.emergency.wechat.manager.search.consumer.service.fallback_factory
 * Date: 2019/3/25
 *
 * @author: 快乐的小菌菌
 * Description:
 */
@Component
public class ManagerSearchFallbackFactory implements FallbackFactory<ManagerSearchConsumer> {
    @Override
    public ManagerSearchConsumer create(Throwable throwable) {
        return new ManagerSearchConsumer() {
            @Override
            public String flipList(Integer pageNo, Integer pageSize) {
                return ResponseEntity.error(StatusCode.DB_SAVE_ERROR, "按条件查询管理员列表失败！", throwable.getMessage());
            }

            @Override
            public String login(String userName, String password) {
                return ResponseEntity.error(StatusCode.DB_SAVE_ERROR, "登录失败！", throwable.getMessage());
            }

            @Override
            public String updateToken(Long id) {
                return ResponseEntity.error(StatusCode.DB_SAVE_ERROR, "更新Token失败！", throwable.getMessage());
            }

            @Override
            public String getById(Long id) {
                return ResponseEntity.error(StatusCode.DB_SAVE_ERROR, "根据id获取人员信息失败！", throwable.getMessage());
            }
        };
    }
}
